﻿package mortal.game.view.yyZiZuan
{
    import com.mui.controls.*;
    import com.mui.utils.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class YYZiZuanTagCellRender extends GCellRenderer
    {
        private var _categoryBg:GImageBitmap;
        private var _categoryData:YYZiZuanCategoryData;
        private var _selectSkin:GImageBitmap;
        private var _hitAreaSpr:GSprite;

        public function YYZiZuanTagCellRender()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = UICompomentPool.getUICompoment(GSprite);
            addChild(_loc_1);
            this._selectSkin = UIFactory.gImageBitmap(ImagesConst.YYZiZuanTagSelectSkin, 0, 0, _loc_1);
            this._selectSkin.visible = false;
            this._categoryBg = UIFactory.gImageBitmap("", 0, 8, this);
            Dispatcher.addEventListener(EventName.YYZiZuanSwicthPanel, this.onSwitch);
            this.hitArea = _loc_1;
            return;
        }// end function

        private function onSwitch(event:DataEvent) : void
        {
            if (this._listData.index == int(event.data))
            {
                this.selected = true;
                this._selectSkin.visible = true;
            }
            else
            {
                this.selected = false;
                this._selectSkin.visible = false;
            }
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this._categoryData = param1 as YYZiZuanCategoryData;
            if (this._categoryData)
            {
                this._categoryBg.imgUrl = this._categoryData.resName;
                this._categoryBg.x = this._categoryData.xPos;
            }
            this.playEffect();
            return;
        }// end function

        private function playEffect() : void
        {
            var _loc_1:* = Cache.instance.YYZiZuan;
            if (this._categoryData && this._categoryData.type == 1 && _loc_1.yyZiZuanType > 0 && !_loc_1.isMonthGet)
            {
                EffectManager.glowFilterReg(this._categoryBg);
            }
            else if (this._categoryData && this._categoryData.type == 2 && _loc_1.yyZiZuanType > 1 && !_loc_1.isYearGet)
            {
                EffectManager.glowFilterReg(this._categoryBg);
            }
            else
            {
                EffectManager.glowFilterUnReg(this._categoryBg);
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            Dispatcher.removeEventListener(EventName.LotteryExchangeSwitchPanel, this.onSwitch);
            this._categoryBg.dispose(param1);
            this._selectSkin.dispose(param1);
            this._categoryBg = null;
            this._selectSkin = null;
            this._categoryData = null;
            super.disposeImpl(param1);
            return;
        }// end function

    }
}
